export default {
    namespaced: true,
    state: {
        //控制是否显示提示框
        isShowToast: false,
        //提示信息
        toastMsg: '默认提示',
        //提示图标（success成功。danger失败。warning警告）
        toastType: 'warning'
    },
    mutations: {
        //修改状态
        //payload:{isShowToast:'',msg:'',type:''}
        chengeShowToast(state, payload) {
            state.isShowToast = payload.isShowToast;
            if (payload.isShowToast) {
                state.toastMsg = payload.toastMsg;
                state.toastType = payload.toastType;
            }
        }
    },
    actions: {
        asyncIsShowToast({ commit }, payload) {
            //1.调用mutations修改isshow,msg,type
            commit("chengeShowToast", payload)
            //2.增加定时器，2s后，调用mutations修改isshow：false
            setTimeout(() => {
                commit("chengeShowToast", {
                    isShowToast: false
                })
            }, 2000)
        }
    }
}